<script type="text/javascript" >
    stFacebookToolbox.load_tooltip();
    stFacebookToolbox.on_submitform('#settingForm');
    stFacebookToolbox.sortColumn();
</script>
<style>
    #stcontainer ul.menu_right li a.anchor:hover{
        color:#000000;
}
</style>
<div class="w100p bgl">
    <div class="w100p bgr p5b">
                <ul class="menu_right">
                      <li class="current">
                          <a href="javascript:void(0);" onclick="stFacebookToolboxcustom.loadPage('like_analytics');" id="Statistics">Statistics</a>
                    </li>
                    <li>
                          <a href="javascript:void(0);" onclick="stFacebookToolboxcustom.loadPage('like_daily_change&month=<?php echo date('m');?>&year=<?php echo date('Y');?>&site_id='+jQuery('#domain').val());" id="daily_change">Daily change</a>
                    </li>
                    <li>
                          <a href="javascript:void(0);" onclick="stFacebookToolboxcustom.loadPage('like_aggregated&month=<?php echo date('m');?>&year=<?php echo date('Y');?>&site_id='+jQuery('#domain').val());" id="aggregated">Aggregated</a>
                    </li>
                    <li>
                        <a class="button add-new-h2 anchor" onclick="stFacebookToolboxcustom.update_statistics(0);" style="cursor: pointer;top:0px;">
                       <b>Update statistics</b>
                    </a>
                    </li>
                </ul>
                <p></p>

        <input type="hidden" id="total" value="<?php echo $total;?>" />
        <?php
        foreach($site_id as $si)
            $s[] = $si->id;
        ?>
        <input type="hidden" id="site_id" value="<?php echo implode(',',$s);?>" />
        <input type="hidden" id="picture" value="<?php echo $plugin_url;?>images/mini-loading.gif" />
        <p align="center" id="update_statistics" align="center"></p>
        &nbsp;&nbsp;&nbsp;&nbsp;Filter by site:
        <select name="domain" id="domain" style="margin-bottom:10px;margin-left:10px;" onchange="stFacebookToolboxcustom.loadPage('like_analytics&site_id='+this.value)">
            <option value="all">all</option>
            <?php foreach($sitemap as $site):?>
            <option value="<?php echo $site->id;?>" <?php if($site_id2 == $site->id){echo 'selected';} ?>><?php echo $site->site_name;?></option>
            <?php endforeach;?>
            
        </select>
<table class="widefat" cellspacing="0">
                <thead>
                    <tr>
                        <?php print_column_headers('stFacebookToolbox_stFacebookToolbox'); ?>
                    </tr>
                </thead>

                <tbody>
                <?php
                if (count($results) > 0) {
                    $tr_class = "";
                    $upload_data = wp_upload_dir();
		    $total_total = 0;
                    $total_like = 0;
                    $total_share = 0;
                    $total_comment = 0;
                    $total_click = 0;
                    foreach ($results as $result) {
                       if( empty($tr_class) || $tr_class == "class='bg_gray2'"){
                            $tr_class = "class='bg_gray1'";
                        }else{
                            $tr_class = "class='bg_gray2'";
                        }
                        echo "<tr id='$result->id' $tr_class >"
                        . "<td><a href='{$result->url}' target='_blank'>" . $result->url. "</a></td>"
                        . "<td>" . $result->like_count
                         . "<td>" . $result->share_count . "</td>"
                         . "<td>" . $result->comment_count . "</td>"
                         . "<td>" . $result->click_count. "</td>"
                        . "<td>".$result->total_like."</td>"
                        . "</tr>"
                        ;
                        $total_like += $result->like_count;
                        $total_share += $result->share_count;
                        $total_comment += $result->comment_count;
                        $total_click += $result->click_count;
			$total_total += $result->total_like;
                    }
                }
                ?>
                    <tr style="font-weight:bold;">
                        <td>All</td>
                        <td><?php echo $total_like;?></td>
                        <td><?php echo $total_share;?></td>
                        <td><?php echo $total_comment;?></td>
                        <td><?php echo $total_click;?></td>
                        <td><?php echo $total_total;?></td>
                    </tr>
                </tbody>
            </table>
<!--            <center>Total : <?php echo $number_total;?></center>-->
            <div class="page_d">
                <?php echo $pagination?>
                <div class="cl"></div>
            </div>
    </div>
</div>
